<template>
  <div>
    <el-radio-group v-model="userPostModel" style="position: absolute;left: 70px;top: 10px;font-size: 25px !important;"
                    @click="userPostClick">
      <el-radio-button v-for="dict in userPostArray" :key="dict.dictValue"
                       :value="dict.dictValue">{{
          dict.dictLabel
        }}
      </el-radio-button>
    </el-radio-group>
    <doctor-common v-if="userPostModel ==='2'"/>
    <nurse-common v-else-if="userPostModel ==='3'"/>
  </div>

</template>

<script lang="ts" setup>
import {useDictStoreHook} from "@/store/modules/dict.ts";

const {proxy} = getCurrentInstance() as any

const dictStore = useDictStoreHook();
const dictDataMap = ref(
  dictStore.isTypeGetData(
    "user_post_dict"
  )
);

const userPostModel = ref()
const userPostArray = ref([])

const props = defineProps({
  userInfo: {
    type: Object,
    default: []
  }
})

/**
 * 岗位切换
 */
function userPostClick() {
  console.log("userPostModel", userPostModel)
}

// 获取登录用户信息
const getUserFun = () => {
  const user: any = props.userInfo
  const userPostArrayThis = user.userPostArray
  const userPostDict = dictDataMap.value['user_post_dict']
  userPostArray.value = []
  const postArray: any = []
  if (userPostArrayThis) {
    userPostArrayThis.forEach(item => {
      const index = userPostDict.findIndex((itemDict: any) => {
        return item == itemDict.dictValue
      })
      if (index > -1) {
        postArray.push(userPostDict[index])
      }
    })
    userPostArray.value = postArray
    if (userPostArray.value) {
      userPostModel.value = userPostArray.value[0].dictValue
    }
  }
}

getUserFun()
</script>
<script lang="ts">


export default {
  name: "DashboardIndex"
}

</script>
<style lang="scss" scoped>


</style>
